#ifndef PATH_H
#define PATH_H

#include <QGraphicsItem>

using namespace std;

class Node;
class Sensor;
class Title;
class TreeModel;
class SceneView;

class Path : public QObject, public QGraphicsLineItem
{
	Q_OBJECT
public:

	Path(SceneView *_parentScene, Node *sourceNode, Node *destNode, bool _visibleTitle = true, double _leakagePos = -1,
		double _as = 0, double _ad = 0, double _ms = 0, double _md = 0);
	Path(Node * sourceNode);
	~Path();
	void adjust(QPointF _sourcePoint = QPointF(), QPointF _destPoint = QPointF());
	QRectF boundingRect() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void addTitle(Title *_title);
	void setEnabled(bool b);
	bool enabled(){ return enable; }
	void setSensor(Sensor *sensor);
	void initModel();
	void setScriptSelection(bool s) { scriptSelection = s; }
	Node *source, *dest;
	TreeModel* model;
	Title *title;
	vector<Sensor*> sensorList;
	double leakagePos;
	double additive_stochastic, additive_deterministic; 
	double multiplicative_stochastic, multiplicative_deterministic;
protected:
	void mousePressEvent(QGraphicsSceneMouseEvent *event);
	void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
	QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
	SceneView *parentScene;
	QPointF sourcePoint;
	QPointF destPoint;
	bool enable;
	bool  virtualPath;
	bool visibleTitle;
	bool scriptSelection;
private slots:
	void getModelData(QString name, bool dispTitle, double leakagePos,
		double _additive_stochastic = 0, double _additive_deterministic = 0, 
		double _multiplicative_stochastic = 0, double _multiplicative_deterministic = 0);
	void updateTree();
signals:
	void setModelData(QString name, QString sourceName, QString destName, bool dispTitle, double _leakagePos,
		double _additive_stochastic = 0, double _additive_deterministic = 0, 
		double _multiplicative_stochastic = 0, double _multiplicative_deterministic = 0);
	void pathChangedSelection(Path *path, bool selected);
};

#endif